<?php
/**
 * oscshop2 B2C电子商务系统
 *
 * ==========================================================================
 * @link      http://www.oscshop.cn/
 * @copyright Copyright (c) 2015-2017 oscshop.cn. 
 * @license   http://www.oscshop.cn/license.html License
 * ==========================================================================
 *
 * @author    李梓钿
 *
 * 文章 
 */
namespace osc\common\service;
use think\Db;
class Article{		

	function get_article_by_cid($param=array()){
		
		$map['id']=['gt',0];
		$query=array();
		
		if(isset($param['id'])){		
			$map['id']=['eq',$param['id']];
			$query['id']=$param['id'];
		}
		
		if(isset($param['status'])){		
			$map['status']=['eq',$param['status']];
			$query['status']=$param['status'];
		}else{
			if($param['show_type']=='home')
			$map['status']=['eq',1];
		}
		
		return Db::name('article')->where($map)->order('id desc')->paginate(config('page_num'),false,['query'=>$query]);	
		
	}
	
	function get_article_data($id){
		
		return Db::view('Article','title,author,create_time')
		->view('ArticleData','*','Article.id=ArticleData.article_id')	
		->where('Article.id','eq',(int)$id)	
		->find();			
	}

}
